 
(function($){
	$.fn.multipleImages = function(name) {

		this.each(function(){
				
			var obj = $(this);
			var count = 0;
			$(obj).find("li").each(function(){
				count++;
			});
			
			// On ajoute un petit formulaire pour ajouter des items
			$(obj).after("<input type='hidden' id='"+name+"_count' name='"+name+"_count' value='"+count+"' /><div class='add'><input class='addImage' type='button' value='Ajouter une image' /></div>");
			
			$(obj).parent().find(".addImage").click(function(){
				addImage(name);
			});
			
			function addImage(name){
				var inner = '';
				inner += '<li>' ;
				inner += '    <input' ;
				inner += '        class="firstInput"' ;
				inner += '        type="file"' ;
				inner += '        name="'+name+'_'+count+'" />' ;
				inner += '</li>' ;
				$(obj).append(inner) ;
				
				count++;
				$(obj).parent().find("#"+name+"_count").val(count);
			}
		});
		// On continue le chainage JQuery
		return this;
	};})(jQuery);